package com.ruoyi.video.service.impl;

import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.video.domain.BusVideoInfo;
import com.ruoyi.video.mapper.VideoInfoMapper;
import com.ruoyi.video.service.IVideoInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VideoInfoServiceImpl implements IVideoInfoService {

    @Autowired
    private VideoInfoMapper videoInfoMapper;

    @Override
    public BusVideoInfo selectVideoById(Long videoId) {
        return videoInfoMapper.selectVideoById(videoId);
    }

    @Override
    public List<BusVideoInfo> selectVideoByIdList(List<Long> videoIdList) {
        return videoInfoMapper.selectVideoByIdList(videoIdList);
    }

    @Override
    public List<BusVideoInfo> selectVideoList(BusVideoInfo videoInfo) {
        return videoInfoMapper.selectVideoList(videoInfo);
    }

    @Override
    public List<BusVideoInfo> selectVideoListGroupByTypeLimit5() {
        return videoInfoMapper.selectVideoListGroupByTypeLimit5();
    }

    @Override
    public void formatVideoList(List<BusVideoInfo> videoInfoList, List<SysDictData> videoTagDictList, List<SysDictData> videoTypeDictList) {
        if (videoInfoList == null || videoInfoList.size() == 0) {
            return ;
        }
        for (BusVideoInfo videoInfo : videoInfoList) {
            for (SysDictData dictData : videoTagDictList) {
                if (videoInfo.getVideoTag().equals(dictData.getDictValue())) {
                    videoInfo.setVideoTag(dictData.getDictLabel());
                    break ;
                }
            }
            for (SysDictData dictData : videoTypeDictList) {
                if (dictData.getDictValue().equals(videoInfo.getVideoType())) {
                    videoInfo.setVideoType(dictData.getDictLabel());
                    break ;
                }
            }
        }
    }

    @Override
    public int insertVideo(BusVideoInfo videoInfo) {
        return videoInfoMapper.insertVideo(videoInfo);
    }

    @Override
    public int updateVideo(BusVideoInfo videoInfo) {
        return videoInfoMapper.updateVideo(videoInfo);
    }

    @Override
    public int deleteVideoById(Long videoId) {
        return videoInfoMapper.deleteVideoById(videoId);
    }

    @Override
    public int deleteVideoByIds(Long[] videoIds) {
        return videoInfoMapper.deleteVideoByIds(videoIds);
    }
}
